/**
 * 定义月报表模块
 */
(function(window, angular, undefined){
	var module = angular.module('water.apps.sw.reportData.monthDataManager', ['water.apps.common.report.reportFormBase',
	                                                                          'water.common.dateUtil']);
	
	module.controller('reportDataMonthManagerController',function($scope,$monitorDataService,$controller,$dateUtil){

		var control = $controller("commonReportFormController",{$scope:$scope});
		
		/**
		 * 年选择下拉数据
		 */
		$scope.yearlist = [{name:'2016年',value:2016},{name:'2017年',value:2017}];
		/**
		 * 月现在下拉
		 */
		$scope.monthlist = [];
		/**
		 * 选择的年份
		 */
		$scope.selectYear;
		/**
		 * 选择的月份
		 */
		$scope.selectMonth;
		
		$scope.dataAPIName = 'getMonthReport';
		$scope.dataExportAPIName = "exportMonthExcel";
		
		for(var i=1; i<=12; i++){
			$scope.monthlist.push({
				name:i+"月",
				value:i
			});
		}
		
		/**
		 * 获取查询参数
		 * forExcel 是否用于导出
		 */
		$scope.getQueryObject = function(){
			
			var dateStr = $scope.selectYear + "/" + $scope.selectMonth + "/1 00:00:00";
			var startDate = $dateUtil.createDate(dateStr);
			var endDate = $dateUtil.addMonth(startDate,1);
//			endDate =  $dateUtil.addDay(endDate,-1);
			endDate =  $dateUtil.addSecond(endDate,-1);
			
			var parmsStr = $scope.selectedModel.parmToChecksStr;
			var queryObject = {
					"MN":$scope.selectedModel.MN,
					"PARMS":parmsStr,
					"START":$dateUtil.formatDate(startDate),
					"END":$dateUtil.formatDate(endDate)
				};
			return queryObject;
		}
		
		function _init(){
			var date = new Date();
			$scope.selectYear = date.getFullYear();
			$scope.selectMonth = date.getMonth() + 1;
		}
		
		_init();
		
	});
}(window, angular));